Convex hull trick
Not to be confused with convex hull, the convex hull trick is a dynamic programming optimization technique. It can be thought of as a data structure supporting the following operations:
- Insert(ax+b): insert the line into the data structure
- GetMin(x): considering all the lines that have been inserted so far, return the one that has the minimum value at
Applicability
The convex hull trick applies when the dynamic programming recurrence is approximately of the form
where and . The naive way of computing this recurrence with dynamic programming takes time, but only takes time with the convex hull trick. The restrictions on and can be dropped at the expense of a more complex and slightly slower approach.
TODO: Talk about dynamic vs. static variants
Sometimes the above form appears within a more complex recurrence, as is the case for
The approach remains very similar, and in this case the convex hull trick brings the time complexity down to from . This latter form can also be computed quickly using the divide and conquer optimization
Problems
- Commando
- Land Acquisition
- Batch Scheduling
- Covered Walkway
- Branch Assignment
- Good Inflation
- Cats Transport1
- Cow School2
- Kalila and Dimna in the Logging Industry3
- Leaves
- Squared Ends

